// 联合数据类型
let str1: string | number = 'abc';
console.log(str1)


// 交叉数据类型
let obj: { username: string } = {username: 'zhang'}
console.log(obj.username)

type obj2 = { username: string }
type obj3 = { age: number }
let obj3: obj2 & obj3 = {username: 'zhang', age: 40}
console.log(obj3)

type DataFlow = string | number

function data(dataflow: DataFlow) {
    if (typeof dataflow === 'string') {
        console.log(dataflow.length);
    } else {
        console.log(dataflow.toFixed(2));
    }
}
data('12323')



